import java.io.IOException;
import java.util.*;


public class TextParserNew {
	private static Map<Integer, Set<String>> wordsExistingCheckerByHash;


	public static Map<Integer, Set<String>> parseWords(Set<String> setOfWords) throws IOException {
		wordsExistingCheckerByHash = new HashMap<Integer, Set<String>>();
		for ( String string : setOfWords ) {
				char[] wordAsArray = string.toCharArray();
				Arrays.sort(wordAsArray);
				int hasCode = Arrays.hashCode(wordAsArray);
				if ( wordsExistingCheckerByHash.containsKey(hasCode) ) {
					wordsExistingCheckerByHash.get(hasCode).add(string);
				} else {
					Set<String> newSetOfWords = new HashSet<String>();
					newSetOfWords.add(string);
					wordsExistingCheckerByHash.put(hasCode, newSetOfWords);
				}

		}
		return wordsExistingCheckerByHash;
	}
}
